package com.wiscamp.ninechapters.tags.domain.repositories;

import com.wiscamp.ninechapters.tags.domain.models.Entity;
import com.wiscamp.ninechapters.tags.domain.models.KnowledgePoint;
import com.wiscamp.ninechapters.tags.domain.models.Tag;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;

import java.util.Collection;

public interface EntityRepository {
    // region entity
    Entity getEntity(@Min(0) long entityId);

    Entity getEntityByCode(@NotBlank String entityCode, @Min(0) long appId);

    Collection<Entity> getEntitiesByName(@NotBlank String entityName, @Min(0) long appId);

    Collection<Entity> getEntitiesByApplication(@Min(0) long appId);

    Entity saveEntity(@NotNull Entity entity);



    // endregion

    // entityTag
    boolean bindTag(long appId, long entityId, long primaryKeyId, long tagId);

    boolean unbindTag(long appId, long entityId, long primaryKeyId, long tagId);

    Collection<Tag> getTagsByPrimaryKey(long entityId, long primaryKeyId);

    Collection<Long> getPrimaryIdsByTags(@Min(0) long entityId,
                                         @NotEmpty Collection<Long> tagIds);

    // endregion

    // region entityPoint
    boolean bindKnowledgePoint(long appId, long entityId, long primaryKeyId, long pointId, boolean isPrimary);

    boolean unbindKnowledgePoint(long appId, long entityId, long primaryKeyId, long pointId);

    Collection<KnowledgePoint> getKnowledgePointsByPrimaryKey(long entityId, long primaryKeyId);

    Collection<KnowledgePoint> getKnowledgePointsByPrimaryKey(long entityId, long primaryKeyId, boolean isPrimary);

    Collection<KnowledgePoint> getKnowledgePointsByPrimaryKeys(@Min(0) long entityId,
                                                               @NotEmpty Collection<Long> primaryKeyIds);

    Collection<Long> getPrimaryKeyIdsByKnowledgePoints(@Min(0) long entityId,
                                                       @NotEmpty Collection<Long> pointIds);

    long countPrimaryKeyIdsByPoint(@Min(0) long entityId, @Min(0) long pointId);

    // endregion
}
